import json
from models import BaseModels
from sqlalchemy import Column, String, BigInteger, DateTime, Time


class Owner(BaseModels):
    __tablename__ = 'owner'
    id = Column(BigInteger, autoincrement=True, primary_key=True, unique=True, nullable=False)
    name = Column(String(64), nullable=False, comment="班次名称")
    start = Column(Time, nullable=False, comment="开始时间")
    finish = Column(Time, nullable=False, comment="结束时间")

    def __repr__(self):
        return json.dumps({
            "owner_id": self.id,
            "name": self.name,
            "start": self.start.strftime("%H:%M:%S"),
            "finish": self.finish.strftime("%H:%M:%S")
        })
